<?php

namespace pmvc\mvc\view\twig;

use pmvc\util\ClassUtil;

use pmvc\mvc\ViewHandler;

class TwigViewHandler
	implements ViewHandler {

	private $registerAutoLoader		= true;
	private $autoLoaderPath 		= 'Twig/Autoloader.php';
    private $templatePaths			= Array();
    private $debug					= null;
    private $charset				= null;
    private $baseTemplate_class		= null;
    private $cacheDir				= null;
    private $autoReload				= null;
    private $strict					= null;
    private $autoEscape				= null;
    private $extensions				= Array();
    
    /**
     * {@inheritDoc}
     */
	public function renderView(Request $request, Response $response, $viewName) {

		// register the auto loader
		if ($this->registerAutoLoader===true) {
			if (!ClassUtil::requireFile($this->autoLoaderPath, TRUE)) {
				require_once($this->autoLoaderPath);
			}
			\Twig_Autoloader::register();
		}

		// create the loader
		$loader = new \Twig_Loader_Filesystem($this->templatePaths);

		// create enviornment options array
		$envOptions = Array();
		$setEnvFun = function($name, $value)use($envOptions) {
			if (isset($value)) {
				$envOptions[$name] = $value;
			}
		};
		$setEnvFun("debug",					$this->debug);
		$setEnvFun("charset",				$this->charset);
		$setEnvFun("base_template_class",	$this->base_template_class);
		$setEnvFun("cache",					$this->cacheDir);
		$setEnvFun("auto_reload",			$this->autoReload);
		$setEnvFun("struct_variables",		$this->strict);
		$setEnvFun("auto_escape",			$this->autoEscape);

		// create the environment
		$env = new \Twig_Environment($loader, $envOptions);

		// add 
	}

		
}

?>